//
//  TextFieldCell.m
//  UILbrary
//
//  Created by mac on 16/7/19.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "TextFieldCell.h"

@interface TextFieldCell ()<UITextFieldDelegate>
@property (nonatomic,strong) NSArray *titleArr;
@end

@implementation TextFieldCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubviews];
    }
    return self;
}



- (void)createSubviews{
    [self.contentView addSubview:self.textField];
}


#pragma mark - UITextField delegate
- (void)textFieldDidEndEditing:(UITextField *)textField{
    self.cellTextBlock(textField.text,nil);
}
#pragma mark - lazy
- (UITextField *)textField{
    if (!_textField) {
        _textField = [[UITextField alloc] initWithFrame:self.bounds];
        _textField.borderStyle = UITextBorderStyleRoundedRect;
        _textField.leftView = self.leftViewLable;
        _textField.leftViewMode = UITextFieldViewModeAlways;
        _textField.delegate = self;
    }
    return _textField;
}

- (UILabel *)leftViewLable{
    if (!_leftViewLable) {
        _leftViewLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0,100, self.bounds.size.height)];
        _leftViewLable.backgroundColor = [UIColor orangeColor];
        _leftViewLable.textColor = [UIColor whiteColor];
        _leftViewLable.textAlignment = NSTextAlignmentCenter;
    }
    return _leftViewLable;
}


@end
